home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
keyb
/
pan.zip
/
PAN.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-02-22
|
61KB
|
2,297 lines
title 'PAN: Program ANimator by Pete Maclean'
include pan.hdr
; Symbol definitions
CR = 13 ; ASCII carriage return
LF = 10 ; ASCII linefeed
TAB = 9 ; ASCII Tab
; BIOS Keyboard Buffer definitions
KBB_SEGADD = 40h ; segment address of buffer
KBB_HEAD = 1Ah ; offset to head pointer
KBB_TAIL = 1Ch ; offset to tail pointer
KBB_START = 80h ; offset to start pointer
KBB_END = 82h ; offset to end pointer
; PAN States
PS_INITIAL = 0 ; initial state - no target program loaded
PS_LOADED = 1 ; target program loaded
PS_RUNNING = 2 ; target program running
PS_OBIT = 3 ; waiting for target program to die
PS_QUIT = 4 ; QUIT pending when target program dies
code segment para public 'code'
assume cs:code, ds:code
org 100h
start: jmp main ; entry point
; Messages
initmsg db 'PAN 1.0 (c) 1990 Ziff Communications Co.',CR,LF
db 'PC Magazine ',254,' Pete Maclean',CR,LF,'$'
crlfz db CR,LF,0
; Definition for command-table entry
COMMAND STRUC
PC_KEY dw ? ; (offset) address of command key
PC_PROC dw ? ; (offset) address of command processor
PC_TYPE db ? ; coded command type
COMMAND ENDS
command_entry_size db SIZE COMMAND
; Command types
PCT_REG = 0 ; regular command
PCT_IF = 2 ; If command
PCT_ELSE = 4 ; Else command
PCT_FI = 6 ; EndIf command
; Command table
command_table LABEL COMMAND
COMMAND <k_Break, c_Break, PCT_REG>
COMMAND <k_Cursor, c_Cursor, PCT_REG>
COMMAND <k_Else, c_Else, PCT_ELSE>
COMMAND <k_EndIf, c_EndIf, PCT_FI>
COMMAND <k_Flush, c_Flush, PCT_REG>
COMMAND <k_GetKey, c_GetKey, PCT_REG>
COMMAND <k_Go, c_Go, PCT_REG>
COMMAND <k_IfKey, c_IfKey, PCT_IF>
COMMAND <k_IfLoad, c_IfLoad, PCT_IF>
COMMAND <k_IfScreen, c_IfScreen, PCT_IF>
jump_command COMMAND <k_Jump, c_Jump, PCT_REG>
COMMAND <k_Key, c_Key, PCT_REG>
label_command COMMAND <k_Label, c_Label, PCT_REG>
COMMAND <k_Load, c_Load, PCT_REG>
COMMAND <k_Lock, c_Lock, PCT_REG>
COMMAND <k_Mode, c_Mode, PCT_REG>
COMMAND <k_Pause, c_Pause, PCT_REG>
COMMAND <k_Output, c_Output, PCT_REG>
COMMAND <k_Quit, c_Quit, PCT_REG>
COMMAND <k_Screen, c_Screen, PCT_REG>
setif_command COMMAND <k_SetIf, c_SetIf, PCT_REG>
COMMAND <k_TypeRate, c_TypeRate, PCT_REG>
COMMAND <k_Unlock, c_Unlock, PCT_REG>
COMMAND <k_Video, c_Video, PCT_REG>
COMMAND <k_WaitChild, c_WaitChild, PCT_REG>
COMMAND <k_WaitScreen, c_WaitScreen, PCT_REG>
COMMAND <k_WaitUntil, c_WaitUntil, PCT_REG>
COMMAND <k_Wipe, c_Wipe, PCT_REG>
JUMP_INDEX = (jump_command - command_table) / SIZE COMMAND
LABEL_INDEX = (label_command - command_table) / SIZE COMMAND
SETIF_INDEX = (setif_command - command_table) / SIZE COMMAND
; Command keywords
command_keys LABEL BYTE
k_Break db "Break",0
k_Cursor db "Cursor",0
k_Else db "Else",0
k_EndIf db "EndIf",0
k_Flush db "Flush",0
k_GetKey db "GetKey",0
k_Go db "Go",0
k_IfKey db "IfKey",0
k_IfLoad db "IfLoad",0
k_IfScreen db "IfScreen",0
k_Jump db "Jump",0
k_Key db "Key",0
k_Label db "Label",0
k_Load db "Load",0
k_Lock db "Lock",0
k_Mode db "Mode",0
k_Pause db "Pause",0
k_Output db "Output",0
k_Quit db "Quit",0
k_Screen db "Screen",0
k_SetIf db " SetIf",0 ; cannot be written
k_TypeRate db "TypeRate",0
k_Unlock db "Unlock",0
k_Video db "Video",0
k_WaitChild db "WaitChild",0
k_WaitScreen db "WaitScreen",0
k_WaitUntil db "WaitUntil",0
k_Wipe db "Wipe",0
db 0 ; end of table marker
; Key table for "On"/"Off" arguments:
on_off db 'OFF',0,'ON',0,0 ; Off is 0, On is 1
; Dispatch table for preprocessing commands by type
preprocessing_table LABEL WORD
dw pp_regular, pp_If, pp_Else, pp_EndIf
; Extra dispatch table for conditional commands
n_table dw n_Nop, n_If, c_Else, c_EndIf
; Miscellaneous stuff
pan_extension db '.PAN',0 ; Standard extension for Pan scripts
pan_sp dw 0 ; SP on transferring to a child program
break_condition db 0 ; ? break on or off
command_ptr dw script_buffer
current_command dw 0 ; pointer to current command in script_buffer
file_handle dw ? ; handle for command file
if_condition db 0 ; IF condition
if_effect_level db 0 ; Level at which last If was TRUE
if_nest_level db 0 ; IF condition level
in_pan_flag db 0 ; set non-zero when in Pan timer intercept
keyboard_feed db 0 ; set when PAN needs exclusive access
; to the keyboard
keyboard_state db 0 ; 0 => unlocked, 1 => locked
kbb_segment dw KBB_SEGADD ; memory segment of keyboard buffer
line_buffer db 128 dup (?) ; buffer for reading text through
pan_state db PS_INITIAL ; see list of PS_xxxx states above
screen_columns db 0 ; number of columns displayed in current video mode
recall_address dw 0 ; address to recall after timer expiry
time_out dw 0 ; time_out counter (ticks)
type_rate dw 0 ; simulation rate for typing
va db 70h ; video attribute, default like DOS MDA
video_segment dw 0 ; memory segment address of video buffer
; Saved BIOS-keyboard interrupt vector
i_BIOS_kb LABEL dword
x_bk_offset dw 0
x_bk_segment dw 0
; Saved timer interrupt vector
i_timer LABEL dword
x_timer_offset dw 0
x_timer_segment dw 0
; Saved keyboard interrupt vector
i_keyboard LABEL dword
x_key_offset dw 0
x_key_segment dw 0
; Saved Ctrl-Break interrupt vector
i_ctrl_break LABEL dwORD
x_break_offset dw 0
x_break_segment dw 0
; Stack pointer from intercept
callers_sp dw 0
callers_ss dw 0
; Last keypress obtained by a GetKey command
keypress LABEL WORD
key_ASCII db 0
key_scan db 0
; Screen position
screen_position LABEL word
n_col db 0 ; column number
n_row db 0 ; row number
; "Keyboard" Input Queue pointers
kiq_first dw 0 ; pointer to first/next character
; Hour and minute for WaitUntil command
until_time LABEL WORD
minute db 0 ; minute to wait for (0 - 60)
hour db 0 ; hour to wait for (0 - 24)
; Parameter block for DOS program-load function
parameter_block LABEL WORD
env_seg dw 0 ; segment of environment string
p_command_line LABEL dwORD ; pointer to command line
command_offset dw 0
command_segment dw 0
FCB1 LABEL dwORD ; FCB pointers
FCB1_O dw 0
FCB1_S dw 0
FCB2 LABEL dwORD
FCB2_O dw 0
FCB2_S dw 0
child_sp dw 0 ; child's SP
child_ss dw 0 ; child's SS
child_ip dw 0 ; child's IP
child_cs dw 0 ; child's CS
; Other information about the child process
child_psp dw 0 ; segment of child's PSP
child_size dw 0 ; size in paragraphs
; Video mode table
vseg_table LABEL BYTE ; Mode Type
db 0B8h ; 0: CGA 40x25 b/w
db 0B8h ; 1: CGA 40x25 16 colors
db 0B8h ; 2: CGA 80x25 b/w
db 0B8h ; 3: CGA 80x25 16 colors
db 0 ; 4: CGA graphics mode
db 0 ; 5: CGA graphics mode
db 0 ; 6: CGA graphics mode
db 0B0h ; 7: MDA 80x25 b/w
; Translation table: ASCII codes into keyboard scan codes
scan db 03, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
; Nul ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
db 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 01, 26, 53, 27, 12
; ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z Esc FS GS RS US
db 57, 02, 40, 04, 05, 06, 08, 40, 10, 11, 09, 13, 51, 12, 52, 53
; sp ! " # $ % & ' ( ) * + , - . /
db 11, 02, 03, 04, 05, 06, 07, 08, 09, 10, 39, 39, 51, 13, 52, 53
; 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
db 03, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
; @ A B C D E F G H I J K L M N O
db 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 26, 43, 27, 07, 12
; P Q R S T U V W X Y Z [ \ ] ^ _
db 41, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
; ` a b c d e f g h i j k l m n o
db 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 26, 43, 27, 41, 14
; p q r s t u v w x y z { | } ~ Del
; Translation table for special keys
keyname_list LABEL BYTE
db 'ESC',0,'TAB',0,'ENTER',0
db 'F1',0,'F2',0,'F3',0,'F4',0,'F5',0,'F6',0,'F7',0,'F8',0,'F9',0
db 'F10',0
db 'HOME